package xyz.kongbai121.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.kongbai121.demo.domain.RespBean;
import xyz.kongbai121.demo.service.IUserWebService;

@RestController
@RequestMapping("/userByWeb")
public class UserWebController {
    @Autowired
    private IUserWebService service;

    @RequestMapping("/login")
    public RespBean loginByWeb(String username,String password){
        String token = service.loginByWeb(username, password);
        return new RespBean(true,token);
    }

    @RequestMapping("/register")
    public RespBean registerByWeb(String token, String username,String password){
        String msg = service.registerByWeb(token, username, password);
        return new RespBean(true,msg);
    }

    @RequestMapping("/update")
    public RespBean updateByWeb(String token, String username,String password){
        String msg = service.updateByWeb(token, username, password);
        return new RespBean(true,msg);
    }

    @RequestMapping("/getUsername")
    public RespBean getUsernameByWeb(String token){
        String username = service.getUsername(token);
        return new RespBean(true,username);
    }
}
